<?php

namespace Library\Widget\TabPane;

class Tab extends \Library\Widget {

	private $_key;
	private $_tabPane;
	private $_title;
	private $_content;
	private $_action;
	
	public function __construct( $key, \Library\Widget\TabPane $tabPane ) {
		parent::__construct();
		$this->_key = $key;
		$this->_tabPane = $tabPane;
	}
	
	public function getTitle() {
		return $this->_title;
	}
	
	public function getContent() {
		return $this->_content;
	}
	
	public function setCurrent() {
		$this->_tabPane->setCurrent( $this->_key );
		return $this;
	}
	
	public function hasContent() {
		return $this->_content !== null;
	}
	
	public function hasAction() {
		return $this->_action !== null;
	}
	
	public function isCurrent() {
		return $this->_tabPane->getCurrent() == $this->_key;
	}
	
	public function getKey() {
		return $this->_key;
	}
	
	public function setTitle( $title ) {
		$this->_title = $title;
		return $this;
	}
	
	public function setAction( \Library\Action\AjaxAction $action ) {
		$this->_action = $action;
		return $this;
	}
	
	public function getAction() {
		return $this->_action;
	}
	
	public function setContent( \Library\View $content ) {
		$this->_content = $content;
		return $this;
	}
	
	public function getTabPane() {
		return $this->_tabPane;
	}
}

